<template>
  <div>
    <h1>深度监听-立即执行</h1>
    <hr>
    <input type="text"
           v-model="obj.name">
    <input type="text"
           v-model="obj.age">
  </div>
</template>

<script>
export default {
  data () {
    return {
      obj: {
        name: 'zs',
        age: 16
      }
    }
  },
  // 当对象里面多个属性，此时obj中的handler是默认监听，deep是深度，immediate是立即执行一次
  watch: {
    obj: {
      handler (newval, oldval) {
        console.log(newval + '====1');
        console.log(oldval + '====2');
      },
      deep: true,
      immediate: true
    }
  }
}
</script>

<style>
</style>